<?php
/**
 * 缓存类
 * @author hemuhan
 *
 */
class mycacheAction extends Action
{
	//获取缓存
	public function getsetting()
	{
		if(S('setting'))
		{
			return ;
		}
		else
		{
			$this->makecache();
		}
		
		if(S('speciality'))
		{
		return;
		}else
		{
			$this->makespeciality();
		}
	}
	
	public function makespeciality()
	{
		S('speciality',null);
		$DB=M('speciality');
		$list = $DB->select();
		foreach($list as $k=>$v)
		{
			$arr[$v['id']] = $v;
		
		}
		S('speciality',$arr);
	}
	
	
	//创建设置缓存
	public function makecache()
	{
		S('setting',null);
		$DB = M('schoolsetting');
		$list = $DB->select();
		$arr= array();
		foreach($list as $k=>$v)
		{
			$arr[$v['type']][$v['id']] = $v['name'];
		}
		S('setting',$arr);
		
		
	}
	
	//重设置缓存
	public function reset()
	{
		$this->makecache();
		$this->makespeciality();
	}
}